package threadLearn.v2;

import java.util.Calendar;
import java.util.Date;
import java.util.Timer;

class MyTask extends java.util.TimerTask{

	@Override
	public void run() {
		System.out.println("任务执行："+System.currentTimeMillis());
	}
	
}

public class TimerTask {
	public static void main(String[] args) {
		Calendar calendar = Calendar.getInstance();
		calendar.add(Calendar.SECOND, 5);
		Date startDate = calendar.getTime();
		
		MyTask task = new MyTask();
		Timer timer = new Timer();
		timer.schedule(task, startDate,1000);
	}
}
